#include "utils.h"
#include "command.h"
#include "cli_network.h"
#include "cli_transfile.h"
#include "cli_handler.h"
#include "cli_auth.h"
#include "beautify.h"

#define TEST

int main(int argc, char *argv[])
{

#ifndef TEST
    if (argc != 3)
    {
        PRINT_INFO("Usage: %s <server_ip> <server_port>", argv[0]);
        return 1;
    }
    const char *server_ip = argv[1];
    int server_port = atoi(argv[2]);
#else
    const char *server_ip = "127.0.0.1";
    int server_port = 8080;
#endif

    chdir("./storage");

    showWelcome();

    int socket_fd = initClientTcp(server_ip, server_port);

    Tunnel_t tunnel;
    int tunnel_fd = connectTunnel(socket_fd, &tunnel);

    UserInfo_t user;
    memset(&user, 0, sizeof(UserInfo_t));
    handleCommand(&user, socket_fd, tunnel_fd);

    closeClientTcp(socket_fd);
    closeClientTcp(tunnel_fd);

    showCat();
    CAT_MSG("Bye bye 喵!");
    // showGod();

    return 0;
}